<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>权限管理</title>
    <th:block th:replace="/back/common_resources::common_css"></th:block>
    <th:block th:replace="/back/common_resources::common_js"></th:block>
</head>

<body class="hold-transition skin-purple sidebar-mini">
<header th:replace="/back/common_header::header"></header>
<aside th:replace="/back/common_aside::aside"></aside>
<div class="wrapper">
    <!-- 内容区域 -->
    <!-- @@master = admin-layout.html-->
    <!-- @@block = content -->

    <div class="content-wrapper">

        <!-- 内容头部 -->
        <section class="content-header">
            <h1>
                角色管理
                <small>权限列表</small>
            </h1>
            <ol class="breadcrumb">
                <li><a th:href="@{/back/admin_index}"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li><a th:href="@{/back/role/all}">角色管理</a></li>
                <li class="active">权限列表</li>
            </ol>
        </section>
        <!-- 内容头部 /-->

        <!-- 正文区域 -->
        <section class="content">

            <!-- .box-body -->
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">列表</h3>
                </div>

                <div class="box-body">

                    <!-- 数据表格 -->
                    <div class="table-box">

                        <!--工具栏-->
                        <div class="pull-left" sec:authorize="hasAnyAuthority('/admin/all')">
                            <div class="form-group form-inline">
                                <div class="btn-group">
                                    <a th:href="@{/back/permission_add}">
                                        <button type="button" class="btn btn-default" title="新建"><i class="fa fa-file-o"></i> 新建</button>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <!--工具栏/-->

                        <!--数据列表-->
                        <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                            <thead>
                            <tr>
                                <th class="" style="padding-right:0px;">
                                    <input id="selall" type="checkbox" class="icheckbox_square-blue">
                                </th>
                                <th>权限名</th>
                                <th>权限详情</th>
                                <th class="text-center">操作</th>
                            </tr>
                            </thead>
                            <tbody>

                                <tr th:each="permission:${permissionPage.records}">
                                    <td><input name="ids" type="checkbox"></td>
                                    <td th:text="${permission.permissionName}"></td>
                                    <td th:text="${permission.permissionDesc}"></td>
                                    <td class="text-center">
                                        <a th:href="@{/back/permission/edit(pid=${permission.pid})}" class="btn bg-olive btn-xs">修改</a>
                                        <a th:onclick="|javascript:del(${permission.pid})|" class="btn bg-olive btn-xs">删除</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <!--数据列表/-->



                    </div>
                    <!-- 数据表格 /-->


                </div>
                <!-- /.box-body -->

                <!-- .box-footer-->
                <div class="box-footer">
                    <div class="pull-left">
                        <div class="form-group form-inline">
                            总共<span th:text="${permissionPage.pages}"></span>页，共<span th:text="${permissionPage.total}"></span> 条数据。
                        </div>
                    </div>
                </div>
                <!-- /.box-footer-->



            </div>

        </section>
        <!-- 正文区域 /-->

    </div>
    <!-- @@close -->
    <!-- 内容区域 /-->
</div>
<footer th:replace="/back/common_footer::footer"></footer>
<script th:inline="javascript">
    function del(pid) {
        if (confirm("确定要删除吗?")) {
            location.href = "/back/permission/delete?pid=" + pid;
        }
    }
    $(function () {
        var currentPage = [[${permissionPage.current}]];
        var pages = [[${permissionPage.pages}]];
        var context = [[${#servletContext.contextPath}]];
        $(".pagination").bootstrapPaginator({
            bootstrapMajorVersion: 3, //bootstrap版本
            currentPage: currentPage, // 当前页
            totalPages: pages, // 总页数
            numberOfPages: 5, // 最多显示多少页
            itemTexts: function (type, page, current) {
                switch (type) {
                    case "first":
                        return "首页";
                    case "prev":
                        return "上一页";
                    case "next":
                        return "下一页";
                    case "last":
                        return "末页";
                    case "page":
                        return page;
                }
            }, onPageClicked: function (event, originalEvent, type, page) { //点击页码执行的方法
                location.href = context + "/back/permission/all?page=" + page;
            }
        });
    })
</script>
</body>

</html>